package com.example.wechathook.hook;

import com.example.wechathook.util.WechatSnsDBHelper;

import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.callStaticMethod;
import static de.robv.android.xposed.XposedHelpers.findAndHookConstructor;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class SnsCommentHook extends BaseHook {

	private static WechatSnsDBHelper mSnsDb;

	@Override
	public void hook(final XC_LoadPackage.LoadPackageParam lpp) {
		findAndHookMethod("com.tencent.mm.plugin.sns.h.l", lpp.classLoader, "com.tencent.mm.sdk.h.d",
				new XC_MethodHook() {
					@Override
					protected void afterHookedMethod(MethodHookParam param) throws Throwable {
						if (mSnsDb == null) {
							mSnsDb = new WechatSnsDBHelper(param.args[0]);
						}
					}
				});

		findAndHookMethod("com.tencent.mm.plugin.sns.ui.SnsTimeLineUI", lpp.classLoader, "a", boolean.class,
				boolean.class, String.class, boolean.class, new XC_MethodHook() {

				});

	}
}
